<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateSysUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if(!Schema::hasTable('sys_users')){

            Schema::create('sys_users', function (Blueprint $table) {
                $table->string('id', 45)->primary()->comment('ID');
                $table->string('username', 45)->unique()->comment('账号');
                $table->string('password', 255)->comment('密码');
                $table->string('name', 45)->comment('姓名');
                $table->string('mobile', 45)->comment('手机号');
                $table->string('email', 45)->unique()->comment('电子邮件');
                $table->string('avatar_url', 100)->nullable()->comment('头像');
                $table->boolean('enabled')->default(0)->comment('是否可用');
                $table->timestamp('locked_expired')->nullable()->comment('锁定过期时间');
                $table->timestamp('active_expired')->nullable()->comment('激活过期时间');
                $table->timestamps();
            });
        }
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('sys_users');
    }
}
